import 'package:flutter/material.dart';
import 'package:flutter_ui/src/theme/colors.dart';
import 'package:flutter_ui/src/theme/sizes.dart';

TextStyle defaultHeaderStyle = TextStyle(fontWeight: FontWeight.w400, fontSize: LargeFontSize);

class Header extends StatelessWidget implements PreferredSizeWidget {
  final String title;
  final Brightness brightness;
  final TextStyle titleStyle;

  @override
  final Size preferredSize;
  Header({Key key, this.title, this.brightness = Brightness.light, this.titleStyle }) : 
    preferredSize = Size.fromHeight(HeaderHeight),
    super(key: key);

  @override
  Widget build(BuildContext context) {
    bool isDart = brightness == Brightness.dark;
    TextStyle _titleStyle = (isDart ? defaultHeaderStyle.copyWith(color: PrimaryTextColor) : defaultHeaderStyle).merge(this.titleStyle);

    return PreferredSize(
        child: AppBar(
          title: Text(title, style: _titleStyle),
          centerTitle: true,
          elevation: 0,
        ),
        preferredSize: preferredSize
    );
  }
}